package cn.wolfcode.luowowo.article.domain;

import cn.wolfcode.luowowo.common.domain.BaseDomain;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

@Setter
@Getter
@ToString
public class Flight extends BaseDomain {
    private Long id;
    //航班名
    private String flightName;
    //航班号
    private String flightNo;
    //起飞机场
    private String startAirport;
     //降落机场
    private String endAirport;
    //起飞时间
    private Date startDate;
    //降落时间
    private Date endDate;
    //价钱
    private BigDecimal price;

    public String getCountDate() {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
        Date d1 = endDate;
        Date d2 = startDate;
        long diff = d1.getTime() - d2.getTime();//这样得到的差值是毫秒级别
        long days = diff / (1000 * 60 * 60 * 24);

        long hours = (diff - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
        long minutes = (diff - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60);
        return hours + "小时" + minutes + "分";
        }catch (Exception e){
        }
        return "666";
    }
}